<?php


namespace app\api\controller;


use think\Controller;
use think\Db;
use think\Request;

class Comment extends Controller
{
    public function add()
    {
        $request = Request::instance();
        $data = $request->param();
        $insert_data = [
            "userid" => $data["userid"],
            "foodid" => $data["foodid"],
            "comment" => $data["comment"],
            "postdate" => $data["postdate"],
            "data_state" => 1,
            "create_time" => date("Y-m-d H:i:s", time()),
            "update_time" => date("Y-m-d H:i:s", time())
        ];
        $result = Db::name("t_comments")->insertGetId($insert_data);
        if ($result) {
            $data = [
                "msg" => "成功",
                "success" => true
            ];
            return $data;
        } else {
            $data = [
                "msg" => "失败",
                "success" => false
            ];
            return $data;
        }

    }
}